<template>
  <div class="block">
    <p>使用 scoped slot</p>
    <el-button @click.native="aler">111</el-button>
    <!--<el-tree-->
      <!--:data="data5"-->
      <!--show-checkbox-->
      <!--node-key="id"-->
      <!--default-expand-all-->
      <!--:expand-on-click-node="false">-->
      <!--<span class="custom-tree-node" slot-scope="{ node, data }">-->
        <!--<span>{{ node.label }}</span>-->
        <!--<span>-->
          <!--<el-button-->
            <!--type="text"-->
            <!--size="mini"-->
            <!--@click="() => append(data)">-->
            <!--Append-->
          <!--</el-button>-->
          <!--<el-button-->
            <!--type="text"-->
            <!--size="mini"-->
            <!--@click="() => remove(node, data)">-->
            <!--Delete-->
          <!--</el-button>-->
        <!--</span>-->
      <!--</span>-->
    <!--</el-tree>-->
    <el-table
      :data="temp"
    >
      <el-table-column
        label="追加评价点"
        fixed
        width="70">
        <!--追加评价点操作为该公司评价人员为自己公司追加操作 不可为其他公司做此操作-->
        <!--select_type0:都没选 1:上级公司发布的 2:当前公司追加的-->
        <!--当前账号属于该公司 切不为顶级公司账号时候 可以为自己追加平价点-->
        <!--判断是否在评价阶段  bl_evaluation  -->
        <template slot-scope="scope"  >
          <!--self_identify==0-->
          <div  class="nocomments">
            <el-checkbox
              :checked="scope.row.select_type===1"
              v-model="scope.row.select_type"
              @change="checked => selectComment(checked, scope.row)" ></el-checkbox>
          </div>
          <!--v-model-->
        </template>
        <!--当账号不属于改公司时候  且不为-->
      </el-table-column>
    </el-table>

  </div>
</template>
<script>
  let id = 1000;
  import treeToArray2 from '@/page/test/catalog.js'
  export default {
    data() {

      const data = [{
        id: 1,
        label: '一级 1',
        children: [{
          id: 4,
          label: '二级 1-1',
          children: [{
            id: 9,
            label: '三级 1-1-1'
          }, {
            id: 10,
            label: '三级 1-1-2'
          }]
        }]
      }, {
        id: 2,
        label: '一级 2',
        children: [{
          id: 5,
          label: '二级 2-1'
        }, {
          id: 6,
          label: '二级 2-2'
        }]
      }, {
        id: 3,
        label: '一级 3',
        children: [{
          id: 7,
          label: '二级 3-1'
        }, {
          id: 8,
          label: '二级 3-2'
        }]
      }];
      return {
        data4: JSON.parse(JSON.stringify(data)),
        data5: JSON.parse(JSON.stringify(data)),
        temp:[],
        id:100
      }
    },

    methods: {
      aler(){
          this.temp=[];
        this.initData(95);
      },
      append(data) {
          console.log(data)
        const newChild = { id: id++, label: 'testtest', children: [] };
        if (!data.children) {
          this.$set(data, 'children', []);
        }
        data.children.push(newChild);
      },

      remove(node, data) {
        const parent = node.parent;
        const children = parent.data.children || parent.data;
        const index = children.findIndex(d => d.id === data.id);
        children.splice(index, 1);
      },
      getformatData() {
        let tmp;
        if (!Array.isArray(this.tableData3)) {
          tmp = [this.tableData3]
        } else {
          tmp = this.tableData3
        };
        const func = this.evalFunc || treeToArray2
        const args = this.evalArgs ? Array.concat([tmp, this.expandAll], this.evalArgs) : [tmp, this.expandAll];
        return func.apply(null, args)
      },
      //获取流程列表
      initData(id){
        this.multipleSelection=[];
        this.tempArr =[];
        this.multipleSelection2=[];
        this.tempArr2 =[];
        var tempi=0;
        this.axios.get('/api/v1/flow/companyevaplan/'+`${id}`)
          .then((res)=>{
            if(res.data.code==0){
              this.loading =false;
              for(var i in res.data.data){
                res.data.data[i].disabledCheck=false;
              };
              this.minLength =res.data.data.length;
              this.tableData3 =res.data.data;
              var active={
                active:1
              };
              this.temp =this.getformatData(res.data.data);
              console.log(this.temp)
            }else{
              this.$alert(res.data.message,'提示')
            }
          }).catch((err)=>{
          this.$alert(err.message,'提示')
        })
      },

    },
    mounted(){
        this.initData(101);
    }
  };
</script>

<style>
  .custom-tree-node {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    padding-right: 8px;
  }
</style>
